package com.taiji.dicom4cloud.smart.alarm.utils;

import com.taiji.dicom4cloud.common.core.utils.CommonUtils;

import java.util.Arrays;

/**
 * 恶性报警
 *
 * @Description
 * @Author fanxl
 * @Date 2021/8/23
 **/
public class MalignantUtils {

    /**
     * 接入报警
     */
    public static byte[] ACCESS_ALARM = {0x00};

    /**
     * 调压器报警
     */
    public static byte[] VOLTAGE_REGULATOR = {0x01};

    /**
     * 恶行负载
     */
    public static byte[] MALIGNANT_LOAD = {0x02};

    /**
     * 获取类型
     *
     * @param message
     * @return
     */
    public static byte[] getType(byte[] message) {
        return Arrays.copyOfRange(message, 0, 1);
    }

    /**
     * 获取报警名称
     * @param message
     * @return
     */
    public static String getAlarmName(byte[] message){
        if(CommonUtils.bytesToShort(getType(message)) == 1){
            return "恶性调压器报警";
        }
        if(CommonUtils.bytesToShort(getType(message)) == 2){
            return "恶性负载报警";
        }
        return null;
    }
}
